home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 January / Pcwk0198.iso / Dzieci / SIMPDATA / SIMPMAIN / 00009_editManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-01  |  17.4 KB  |  527 lines

  1. property theSelectedSprNumber, baseRecordSprOffset, editType
  2. global scoreData, dispatchTable, currentFrame, soundFXData, soundLoopData, dirtyFlag, selectionHiliteSpr, foregroundFXSpr, backgroundFXSpr, theStageBounds
  3.  
  4. on birth me
  5.   set baseRecordSprOffset to 2
  6.   return me
  7. end
  8.  
  9. on hiliteSelectedClip me, whichSpr
  10.   if whichSpr = backgroundFXSpr then
  11.     set the rect of sprite selectionHiliteSpr to inflate(the rect of cast the castNum of sprite whichSpr, -20, -20)
  12.     set the loc of sprite selectionHiliteSpr to point(the left of sprite whichSpr + 20, the top of sprite whichSpr + 20)
  13.   else
  14.     set the rect of sprite selectionHiliteSpr to inflate(the rect of cast the castNum of sprite whichSpr, 2, 2)
  15.     set the loc of sprite selectionHiliteSpr to point(the left of sprite whichSpr - 2, the top of sprite whichSpr - 2)
  16.   end if
  17.   updateStage()
  18. end
  19.  
  20. on selectClip me, whichSpr
  21.   set theSelectedSprNumber to whichSpr
  22.   set editType to #CLIP
  23.   if (whichSpr = foregroundFXSpr) or (whichSpr = backgroundFXSpr) then
  24.     showPalette(paletteMgr, #partialEdit)
  25.   else
  26.     showPalette(paletteMgr, #FullEdit)
  27.   end if
  28.   hiliteSelectedClip(me, whichSpr)
  29. end
  30.  
  31. on moveClip me, whichSpr
  32.   set theSelectedSprNumber to whichSpr
  33.   set offsetH to the mouseH - the locH of sprite theSelectedSprNumber
  34.   set offsetV to the mouseV - the locV of sprite theSelectedSprNumber
  35.   repeat while the mouseDown
  36.     set theMouseLoc to point(the mouseH, the mouseV)
  37.     if inside(theMouseLoc, theStageBounds) then
  38.       set theMouseH to the mouseH
  39.       set theMouseV to the mouseV
  40.       set the loc of sprite theSelectedSprNumber to point(theMouseH - offsetH, theMouseV - offsetV)
  41.     end if
  42.     updateStage()
  43.   end repeat
  44.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  45.   set theChannelNumber to getAt(getAt(dispatchTable, theSlotNumber), 3)
  46.   set referenceClip to getAt(getAt(scoreData, currentFrame), theChannelNumber)
  47.   setAt(referenceClip, 2, the locH of sprite theSelectedSprNumber)
  48.   setAt(referenceClip, 3, the locV of sprite theSelectedSprNumber)
  49.   setAt(getAt(scoreData, currentFrame), theChannelNumber, referenceClip)
  50.   set dirtyFlag to 1
  51. end
  52.  
  53. on confirmBurnScene me
  54.   set numberOfFrames to count(scoreData)
  55.   if numberOfFrames > 0 then
  56.     set numberOfFramesToDelete to numberOfFrames - currentFrame + 1
  57.     if currentFrame = numberOfFrames then
  58.       if currentFrame = 1 then
  59.         set theMessage to "Are you sure you want to delete all the frames in this animation?"
  60.       else
  61.         set theMessage to "Are you sure you want to delete the last frame in this animation?"
  62.       end if
  63.     else
  64.       if numberOfFramesToDelete < numberOfFrames then
  65.         set theMessage to "Are you sure you want to delete all the animation from frame " & currentFrame & " to frame " & numberOfFrames & "?"
  66.       else
  67.         set theMessage to "Are you sure you want to delete all the frames in this animation?"
  68.       end if
  69.     end if
  70.     set theAlertBoxType to #cancel_ok
  71.     showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "burnScene(editMgr)")
  72.   else
  73.     set theMessage to "Hey man there ain't no frames to delete. Make some first okay?"
  74.     set theAlertBoxType to #OK
  75.     showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "nothing")
  76.   end if
  77. end
  78.  
  79. on burnScene me
  80.   set numberOfFrames to count(scoreData)
  81.   set numberOfFramesToDelete to numberOfFrames - currentFrame + 1
  82.   if numberOfFramesToDelete < numberOfFrames then
  83.     removeFrames(listMgr, numberOfFramesToDelete)
  84.     decrementFrame()
  85.     if currentFrame < 1 then
  86.       resetFrameCounter()
  87.     end if
  88.     setKrusty(playbackMgr)
  89.     showFrame(playbackMgr, currentFrame, 0)
  90.     updateDispatchTable(layerMgr)
  91.     set dirtyFlag to 1
  92.   else
  93.     reset(appMgr)
  94.   end if
  95. end
  96.  
  97. on holdClip me, direction
  98.   if editType = #CLIP then
  99.     if direction = 1 then
  100.       holdClipForward(me)
  101.     else
  102.       if direction = -1 then
  103.         holdClipBackward(me)
  104.       else
  105.         holdClipForward(me)
  106.         holdClipBackward(me)
  107.       end if
  108.     end if
  109.   else
  110.     if direction = 1 then
  111.       holdSoundForward(me)
  112.     else
  113.       if direction = -1 then
  114.         holdSoundBackward(me)
  115.       else
  116.         holdSoundForward(me)
  117.         holdSoundBackward(me)
  118.       end if
  119.     end if
  120.   end if
  121.   set dirtyFlag to 1
  122. end
  123.  
  124. on holdClipForward me
  125.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  126.   set theSlot to getAt(dispatchTable, theSlotNumber)
  127.   set theChannelNumber to getAt(theSlot, 3)
  128.   set theType to getAt(theSlot, 1)
  129.   if theType = "P" then
  130.     set theSearchField to getAt(theSlot, 4)
  131.     set theLineCount to the number of lines in field theSearchField
  132.     set theSearchString to string(getAt(theSlot, 2))
  133.     repeat with theLineNumber = 1 to theLineCount
  134.       if value(item 2 of line theLineNumber of field theSearchField) = theSearchString then
  135.         set thePropClipRecord to value(line theLineNumber of field theSearchField)
  136.         exit repeat
  137.       end if
  138.     end repeat
  139.     if not voidp(thePropClipRecord) then
  140.       set theLoopList to getAt(thePropClipRecord, 5)
  141.       set theLoopCount to count(theLoopList)
  142.       set theLoopNumber to 1
  143.       set referenceClip to getAt(getAt(scoreData, currentFrame), theChannelNumber)
  144.       repeat with theFrameNumber = currentFrame + 1 to count(scoreData)
  145.         set newReferenceClip to copyList(referenceClip)
  146.         setAt(newReferenceClip, 1, getAt(theLoopList, theLoopNumber))
  147.         setAt(getAt(scoreData, theFrameNumber), theChannelNumber, newReferenceClip)
  148.         if theLoopNumber < theLoopCount then
  149.           set theLoopNumber to theLoopNumber + 1
  150.           next repeat
  151.         end if
  152.         set theLoopNumber to 1
  153.       end repeat
  154.     end if
  155.   else
  156.     set referenceClip to getAt(getAt(scoreData, currentFrame), theChannelNumber)
  157.     repeat with theFrameNumber = currentFrame + 1 to count(scoreData)
  158.       set newReferenceClip to copyList(referenceClip)
  159.       setAt(getAt(scoreData, theFrameNumber), theChannelNumber, newReferenceClip)
  160.     end repeat
  161.   end if
  162. end
  163.  
  164. on holdClipBackward me
  165.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  166.   set theSlot to getAt(dispatchTable, theSlotNumber)
  167.   set theChannelNumber to getAt(theSlot, 3)
  168.   set theType to getAt(theSlot, 1)
  169.   if theType = "P" then
  170.     set theSearchField to getAt(theSlot, 4)
  171.     set theLineCount to the number of lines in field theSearchField
  172.     set theSearchString to string(getAt(theSlot, 2))
  173.     repeat with theLineNumber = 1 to theLineCount
  174.       if value(item 2 of line theLineNumber of field theSearchField) = theSearchString then
  175.         set thePropClipRecord to value(line theLineNumber of field theSearchField)
  176.         exit repeat
  177.       end if
  178.     end repeat
  179.     if not voidp(thePropClipRecord) then
  180.       set theLoopList to getAt(thePropClipRecord, 5)
  181.       set theLoopCount to count(theLoopList)
  182.       set theLoopNumber to 1
  183.       set referenceClip to copyList(getAt(getAt(scoreData, currentFrame), theChannelNumber))
  184.       repeat with theFrameNumber = 1 to currentFrame - 1
  185.         set newReferenceClip to copyList(referenceClip)
  186.         setAt(newReferenceClip, 1, getAt(theLoopList, theLoopNumber))
  187.         setAt(getAt(scoreData, theFrameNumber), theChannelNumber, newReferenceClip)
  188.         if theLoopNumber < theLoopCount then
  189.           set theLoopNumber to theLoopNumber + 1
  190.           next repeat
  191.         end if
  192.         set theLoopNumber to 1
  193.       end repeat
  194.     end if
  195.   else
  196.     set referenceClip to copyList(getAt(getAt(scoreData, currentFrame), theChannelNumber))
  197.     repeat with theFrameNumber = 1 to currentFrame - 1
  198.       set newReferenceClip to copyList(referenceClip)
  199.       setAt(getAt(scoreData, theFrameNumber), theChannelNumber, newReferenceClip)
  200.     end repeat
  201.   end if
  202. end
  203.  
  204. on deleteClip me, direction
  205.   if editType = #CLIP then
  206.     if direction = 1 then
  207.       deleteClipForward(me)
  208.     else
  209.       if direction = -1 then
  210.         deleteClipBackward(me)
  211.       else
  212.         if theSelectedSprNumber = 2 then
  213.           deleteBackgroundFX(me)
  214.         else
  215.           if theSelectedSprNumber = 16 then
  216.             deleteForegroundFX(me)
  217.           else
  218.             deleteClipThroughOut(me)
  219.           end if
  220.         end if
  221.       end if
  222.     end if
  223.     showFrame(playbackMgr, currentFrame, 0)
  224.   else
  225.     if direction = 1 then
  226.       deleteSoundForward(me)
  227.       deleteSoundFromCurrentFrame(me)
  228.     else
  229.       if direction = -1 then
  230.         deleteSoundBackward(me)
  231.         deleteSoundFromCurrentFrame(me)
  232.       else
  233.         deleteSoundForward(me)
  234.         deleteSoundBackward(me)
  235.         deleteSoundFromCurrentFrame(me)
  236.       end if
  237.     end if
  238.     hideFieldHiliterSpr(appMgr)
  239.     if editType = #snd then
  240.       put EMPTY into field "soundStatusField"
  241.     else
  242.       put EMPTY into field "loopStatusField"
  243.     end if
  244.   end if
  245.   set dirtyFlag to 1
  246. end
  247.  
  248. on deleteClipForward me
  249.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  250.   set theChannelNumber to getAt(getAt(dispatchTable, theSlotNumber), 3)
  251.   set totalFrames to count(scoreData)
  252.   purgeClips(me, currentFrame, totalFrames, theChannelNumber)
  253.   repeat with theFrameNumber = currentFrame to totalFrames
  254.     setAt(getAt(scoreData, theFrameNumber), theChannelNumber, [])
  255.   end repeat
  256.   checkForLeftOvers(me, theChannelNumber, theSlotNumber)
  257. end
  258.  
  259. on deletePropPart me, theChannelNumber
  260.   set theSlotNumber to 1
  261.   set foundSlot to 0
  262.   repeat with theSlot in dispatchTable
  263.     if getAt(theSlot, 3) = theChannelNumber then
  264.       set foundSlot to 1
  265.       exit repeat
  266.     end if
  267.     set theSlotNumber to theSlotNumber + 1
  268.   end repeat
  269.   set totalFrames to count(scoreData)
  270.   purgeClips(me, currentFrame, totalFrames, theChannelNumber)
  271.   repeat with theFrameNumber = currentFrame to totalFrames
  272.     setAt(getAt(scoreData, theFrameNumber), theChannelNumber, [])
  273.   end repeat
  274.   if foundSlot then
  275.     checkForLeftOvers(me, theChannelNumber, theSlotNumber)
  276.   end if
  277. end
  278.  
  279. on deleteClipBackward me
  280.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  281.   set theChannelNumber to getAt(getAt(dispatchTable, theSlotNumber), 3)
  282.   purgeClips(me, 1, currentFrame, theChannelNumber)
  283.   repeat with theFrameNumber = 1 to currentFrame
  284.     setAt(getAt(scoreData, theFrameNumber), theChannelNumber, [])
  285.   end repeat
  286.   checkForLeftOvers(me, theChannelNumber, theSlotNumber)
  287. end
  288.  
  289. on checkForLeftOvers me, theChannelNumber, theSlotNumber
  290.   set isTotallyErased to 1
  291.   repeat with theFrame = 1 to count(scoreData)
  292.     if getAt(getAt(scoreData, theFrame), theChannelNumber) <> EMPTY then
  293.       set isTotallyErased to 0
  294.       exit repeat
  295.     end if
  296.   end repeat
  297.   if isTotallyErased then
  298.     deleteAt(dispatchTable, theSlotNumber)
  299.     updateDispatchTable(layerMgr)
  300.   end if
  301. end
  302.  
  303. on deleteClipThroughOut me
  304.   set theSlotNumber to theSelectedSprNumber - baseRecordSprOffset
  305.   set theChannelNumber to getAt(getAt(dispatchTable, theSlotNumber), 3)
  306.   set totalFrames to count(scoreData)
  307.   purgeClips(me, 1, totalFrames, theChannelNumber)
  308.   repeat with theFrameNumber = 1 to totalFrames
  309.     setAt(getAt(scoreData, theFrameNumber), theChannelNumber, [])
  310.   end repeat
  311.   deleteAt(dispatchTable, theSlotNumber)
  312.   updateDispatchTable(layerMgr)
  313. end
  314.  
  315. on purgeClips me, startFrame, endFrame, theChannelNumber
  316.   set purgeList to []
  317.   repeat with theFrameNumber = startFrame to endFrame
  318.     set curclip to getAt(getAt(scoreData, theFrameNumber), theChannelNumber)
  319.     if curclip <> EMPTY then
  320.       append(purgeList, getAt(curclip, 1))
  321.     end if
  322.   end repeat
  323.   set thePreviousCastNumber to 0
  324.   sort(purgeList)
  325.   repeat with theCastNumber in purgeList
  326.     if theCastNumber <> thePreviousCastNumber then
  327.       unLoadCast(theCastNumber)
  328.       set thePreviousCastNumber to theCastNumber
  329.     end if
  330.   end repeat
  331. end
  332.  
  333. on deleteForegroundFX me
  334.   set countFgdFXData to count(fgdFXData)
  335.   set countScoreData to count(scoreData)
  336.   if countFgdFXData < countScoreData then
  337.     repeat with theFrameNumber = countFgdFXData + 1 to countScoreData
  338.       append(fgdFXData, copyList([]))
  339.     end repeat
  340.   end if
  341.   set fgdFXFrame to getAt(fgdFXData, currentFrame)
  342.   set fgdFXName to getAt(fgdFXFrame, 4)
  343.   repeat with theFrameNum = currentFrame to countScoreData
  344.     set theFrameRecord to getAt(fgdFXData, theFrameNum)
  345.     if theFrameRecord <> EMPTY then
  346.       if fgdFXName = getAt(theFrameRecord, 4) then
  347.         unLoadCast(getAt(theFrameRecord, 1))
  348.         setAt(fgdFXData, theFrameNum, copyList([]))
  349.       else
  350.         exit repeat
  351.       end if
  352.       next repeat
  353.     end if
  354.     exit repeat
  355.   end repeat
  356.   repeat with theFrameNum = currentFrame - 1 down to 1
  357.     set theFrameRecord to getAt(fgdFXData, theFrameNum)
  358.     if theFrameRecord <> EMPTY then
  359.       if fgdFXName = getAt(theFrameRecord, 4) then
  360.         unLoadCast(getAt(theFrameRecord, 1))
  361.         setAt(fgdFXData, theFrameNum, copyList([]))
  362.       else
  363.         exit repeat
  364.       end if
  365.       next repeat
  366.     end if
  367.     exit repeat
  368.   end repeat
  369. end
  370.  
  371. on deleteBackgroundFX me
  372.   set countBgdFXData to count(bgdFXData)
  373.   set countScoreData to count(scoreData)
  374.   if countBgdFXData < countScoreData then
  375.     repeat with theFrameNumber = countBgdFXData + 1 to countScoreData
  376.       append(bgdFXData, copyList([EMPTY, 0]))
  377.     end repeat
  378.   end if
  379.   set bgdFXFrame to getAt(bgdFXData, currentFrame)
  380.   set bgdFXName to getAt(bgdFXFrame, 1)
  381.   repeat with theFrameNum = currentFrame to countScoreData
  382.     set theFrameRecord to getAt(bgdFXData, theFrameNum)
  383.     if theFrameRecord <> EMPTY then
  384.       if bgdFXName = getAt(theFrameRecord, 1) then
  385.         unLoadCast(getAt(theFrameRecord, 2))
  386.         setAt(bgdFXData, theFrameNum, copyList([EMPTY, 0]))
  387.       else
  388.         exit repeat
  389.       end if
  390.       next repeat
  391.     end if
  392.     exit repeat
  393.   end repeat
  394.   repeat with theFrameNum = currentFrame - 1 down to 1
  395.     set theFrameRecord to getAt(bgdFXData, theFrameNum)
  396.     if theFrameRecord <> EMPTY then
  397.       if bgdFXName = getAt(theFrameRecord, 1) then
  398.         unLoadCast(getAt(theFrameRecord, 2))
  399.         setAt(bgdFXData, theFrameNum, copyList([EMPTY, 0]))
  400.       else
  401.         exit repeat
  402.       end if
  403.       next repeat
  404.     end if
  405.     exit repeat
  406.   end repeat
  407. end
  408.  
  409. on editSoundFx me
  410.   if the text of field "soundStatusField" <> EMPTY then
  411.     set editType to #snd
  412.     hiliteSoundFXField(appMgr)
  413.     showPalette(paletteMgr, #partialEdit)
  414.   end if
  415. end
  416.  
  417. on editSoundLoop me
  418.   if the text of field "loopStatusField" <> EMPTY then
  419.     set editType to #LOO
  420.     hiliteSoundLoopField(appMgr)
  421.     showPalette(paletteMgr, #FullEdit)
  422.   end if
  423. end
  424.  
  425. on deleteSoundForward me
  426.   if editType = #snd then
  427.     set theDataList to soundFXData
  428.   else
  429.     set theDataList to soundLoopData
  430.   end if
  431.   if count(theDataList) < count(scoreData) then
  432.     set lastSoundLoop to getLast(theDataList)
  433.     repeat with theFrameNumber = count(theDataList) + 1 to count(scoreData)
  434.       append(theDataList, copyList(lastSoundLoop))
  435.     end repeat
  436.   end if
  437.   set theSound to getAt(theDataList, currentFrame)
  438.   set theSoundCastNum to getAt(theSound, 2)
  439.   repeat with theFrameNum = currentFrame + 1 to count(scoreData)
  440.     set theFrameRecord to getAt(theDataList, theFrameNum)
  441.     if theFrameRecord <> EMPTY then
  442.       if theSoundCastNum = getAt(theFrameRecord, 2) then
  443.         setAt(theDataList, theFrameNum, copyList([EMPTY, 0]))
  444.       else
  445.         exit repeat
  446.       end if
  447.       next repeat
  448.     end if
  449.     exit repeat
  450.   end repeat
  451. end
  452.  
  453. on deleteSoundBackward me
  454.   if editType = #snd then
  455.     set theDataList to soundFXData
  456.   else
  457.     set theDataList to soundLoopData
  458.   end if
  459.   if count(theDataList) < count(scoreData) then
  460.     set lastSoundLoop to getLast(theDataList)
  461.     repeat with theFrameNumber = count(theDataList) + 1 to count(scoreData)
  462.       append(theDataList, copyList(lastSoundLoop))
  463.     end repeat
  464.   end if
  465.   set theSound to getAt(theDataList, currentFrame)
  466.   set theSoundCastNum to getAt(theSound, 2)
  467.   repeat with theFrameNum = currentFrame - 1 down to 1
  468.     set theFrameRecord to getAt(theDataList, theFrameNum)
  469.     if theFrameRecord <> EMPTY then
  470.       if theSoundCastNum = getAt(theFrameRecord, 2) then
  471.         setAt(theDataList, theFrameNum, copyList([EMPTY, 0]))
  472.       else
  473.         exit repeat
  474.       end if
  475.       next repeat
  476.     end if
  477.     exit repeat
  478.   end repeat
  479. end
  480.  
  481. on deleteSoundFromCurrentFrame me
  482.   if editType = #snd then
  483.     set theDataList to soundFXData
  484.   else
  485.     set theDataList to soundLoopData
  486.   end if
  487.   if count(theDataList) < count(scoreData) then
  488.     repeat with theFrameNumber = count(theDataList) + 1 to count(scoreData)
  489.       append(theDataList, copyList([EMPTY, 0]))
  490.     end repeat
  491.   end if
  492.   unLoadCast(getAt(getAt(theDataList, currentFrame), 2))
  493.   setAt(theDataList, currentFrame, copyList([EMPTY, 0]))
  494. end
  495.  
  496. on holdSoundForward me
  497.   set countScoreData to count(scoreData)
  498.   set countSoundLoopData to count(soundLoopData)
  499.   set theReferenceFrame to getLast(soundLoopData)
  500.   if countSoundLoopData < countScoreData then
  501.     repeat with theFrameNumber = countSoundLoopData + 1 to countScoreData
  502.       append(soundLoopData, copyList(theReferenceFrame))
  503.     end repeat
  504.   end if
  505.   set theSound to getAt(soundLoopData, currentFrame)
  506.   repeat with theFrameNum = currentFrame to countScoreData
  507.     setAt(soundLoopData, theFrameNum, copyList(theSound))
  508.   end repeat
  509.   put getAt(theSound, 1) into field "loopStatusField"
  510. end
  511.  
  512. on holdSoundBackward me
  513.   set countScoreData to count(scoreData)
  514.   set countSoundLoopData to count(soundLoopData)
  515.   set theReferenceFrame to getLast(soundLoopData)
  516.   if countSoundLoopData < countScoreData then
  517.     repeat with theFrameNumber = countSoundLoopData + 1 to countScoreData
  518.       append(soundLoopData, copyList(theReferenceFrame))
  519.     end repeat
  520.   end if
  521.   set theSound to getAt(soundLoopData, currentFrame)
  522.   repeat with theFrameNum = currentFrame - 1 down to 1
  523.     setAt(soundLoopData, theFrameNum, copyList(theSound))
  524.   end repeat
  525.   put getAt(theSound, 1) into field "loopStatusField"
  526. end
  527.